Skip to content

Never block setup on how many subscriptions the proxy holds - #286

Draft
Silthus wants to merge 33 commits into
feat/cloud-onlyfrom
fix/proxy-accounts-never-block
Draft

Silthus wants to merge 33 commits into
feat/cloud-onlyfrom
fix/proxy-accounts-never-block

Conversation

@Silthus

@Silthus Silthus commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Setup must never be blocked by how many of your own Claude or ChatGPT subscriptions the hub's own-account proxy holds, none included.

Today, on a fresh hub with the Hub pack and own-account balancing on, hedge apply (and so step "Set up this machine" of hedge setup) fails:

Fix: Step cli-proxy of the hub pack ran, but does not pass its check.
Hedge could not apply your profile.

The step's check, hedge cli-proxy doctor, threw Add at least 2 of your own Claude subscriptions that work; found 0. Setup has no step that adds proxy subscriptions, so it could never pass. Setup's last step, "Check everything", runs hedge doctor, which also failed on the route check Fix: Claude Code cannot reach your own-account proxy… while the pool was empty.

Changes

  • The proxy step passes with a short pool. hedge cli-proxy doctor no longer fails below hub.proxyAccounts. It prints CLI proxy: To do: Add at least 2 of your own Claude subscriptions that work to the proxy; found 0. … Run on the hub, once for each subscription: <login command>. Expired logins still count for nothing, and still get their own warning. A proxy that is down, refuses the key, routes other than fill-first, or runs a foreign plugin still fails as before.
  • A pack check can wait for the person. A check in pack.json can name a todo. When its command exits 4 (waitsForPerson), Hedge prints the todo as a To do: line and fails neither apply nor doctor. The check still does not pass, so config that waits for it stays out. Apply runs a todo check that nothing waits for after the steps, so it can read what a step installed. Doctor ends with "Everything Hedge sets matches your profile. The To do lines above wait for you." A check without a todo, or any other failing code, stays a Fix:.
  • New hedge cli-proxy accounts on the hub counts the working subscriptions of the pooled agent. It exits 0 at hub.proxyAccounts and 4 below it. The Hub pack runs it as cli-proxy-accounts (Claude and both plans) and cli-proxy-codex-accounts (Codex plan), each with a todo that names the login command.
  • Route checks wait for the person while the pool is empty. hedge cli-proxy check [codex] exits 4 when the proxy answers the key with a model list that holds no model for the agent. cli-proxy-client and cli-proxy-codex carry a todo for that case. Every other reason still exits 1 and stays a Fix:, including a reply without a model list or with a model entry that has no id. A subscription list from the management API without a list, or with a row that names no provider, fails the doctor and hedge cli-proxy accounts too.
  • Apply decides config that waits for a check once, after the steps. On a fresh hub, or a hub whose proxy is stopped, the proxy step starts the proxy, so a route check can pass only after it. Apply now runs the provider config adapter (Claude and Codex settings, plugins and MCP servers) once, after the steps. Just before it, apply runs each check that config waits for, and each check with a todo, once, and decides that config from those results. Config that waits for nothing, or for a human step, is decided before the steps as on the base branch. The other adapters still run before the steps. The T3 adapter must, because the peers step uses T3, so a T3 setting can wait only for a human step, not for a check; no pack has such a setting. So a hub with one working subscription and a stopped proxy routes Claude Code in one apply, and an unsafe proxy at the end of apply means no route. A route that an earlier apply wrote stays in place while the steps run, and comes out at the end when its check fails then. When an adapter that runs before the steps throws, such as Jobs on a job id it refuses, apply still runs those checks and the provider config adapter, then fails with the adapter's error, as the base branch, which ran provider config before Jobs, did. A check's finding is its one result: a To do: for 4, a Fix: for any other failing code, and nothing for a pass.
  • The route checks also check that the proxy is safe. On the hub, hedge cli-proxy check and hedge cli-proxy check codex fail while hedge cli-proxy doctor finds the proxy unsafe: a plugin Hedge did not install, or panel files that do not match their pins. Both use doctor's own function, unsafe in packs/hub/lib/cli-proxy.ts. The route config waits for these checks, so the gate's ordinary failing-check path keeps the route out, or takes Hedge's route out, when apply decides config after the steps. That holds whether the route is new or an earlier apply wrote it. A route to a safe proxy stays in place, and apply changes nothing. On a devbox the checks cannot see the hub's plugins folder; the hub's own apply and doctor report it. With the panel off, the route check fails while the panel page or quota-ledger.so is still on disk, whatever it holds; hedge cli-proxy install restarts the proxy and removes both, and the route comes back in the same apply. A link at either path, dangling or not, fails the check with the panel on or off, and the check says to remove the link, then run hedge cli-proxy install, which refuses links. With the panel on, both files are checked against their pins, so no plugin passes on its file name.
  • One writer and one rule for the route. hedge cli-proxy connect writes no Claude or Codex settings itself: it checks the key against the proxy, saves it, and runs hedge apply, which writes the route and records each key it writes. So every route Hedge writes has a record. Hedge removes a Claude or Codex setting only when its record says Hedge wrote it. The route is one unit: the Claude proxy address and key helper, or the Codex model_provider = "hedge-proxy" and its model_providers.hedge-proxy table. Apply writes all of a route or none of it, so it never selects a hedge-proxy table of your own. It removes the recorded keys together. When removing them would leave a key of yours that Claude Code then sends to Anthropic (an apiKeyHelper, ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY), or a Codex model_provider that names a table that is gone, the route stays and apply shows a To do: that names the setting to remove. src/adapters/provider-config/proxy-route.ts holds the route's keys and values, and the Hub pack reads them from it. The base branch also removed any setting that pointed at the proxy's port, which could delete a Codex provider table you wrote yourself.
  • Doctor reads one result of each route check. hedge doctor uses the gate's result of a check that config waits for for both the config drift and the check's line, so the two never disagree when the pool changes between two probes.
  • The route To do: names the model the proxy does not list and points to hedge cli-proxy doctor on the hub, which tells an empty pool apart from a subscription that works but serves no model.
  • The box handover says when a box must keep its own sign-in. When hedge cli-proxy connect on a box saves the key but the proxy serves none of its agents yet, connect prints one of two fixed lines. The hub matches the exact line and prints its own message: the agent there keeps its own sign-in until the proxy serves it. The hub never prints the box's output. When connect fails on the box, the hub names the box, the exit code, and the hub-side command that hands over the same key again and shows connect's own reason: hedge box run <box> -- hedge cli-proxy connect < ~/.config/hedge/cli-proxy.key. That command already exists; this PR adds none.
  • hub.proxyAccounts at 0 passes with an empty pool: the account count, not the floor, decides whether a missing model is a failure.
  • Docs: the Hub pack's setup note, the Recovery setup note, the hedge-hub skill, the hub.proxyAccounts question, step 8 of the root SETUP.md (doctor's closing line for waiting To do: lines, which do not stop setup), and the CHANGELOG.

What reads the result, and why no box moves to an empty proxy

  • Routing. Claude Code and Codex config waits for cli-proxy-client and cli-proxy-codex. Exit 4 is not a pass, so apply keeps each agent on its own sign-in until the proxy serves its model. On the hub, an unsafe proxy fails these checks too, so the gate decides on safety, not the step. The end-to-end test checks that .claude/settings.json and .codex/config.toml stay unwritten with 0 subscriptions.
  • The step check (hedge cli-proxy doctor) only decides whether the step holds. It never routes. Its safety condition reaches routing through the route checks, which call the same function.
  • The balancer job (hedge cli-proxy-balance) reads the management API itself, not the doctor, and handles an empty pool.
  • Recovery asks the proxy directly with the client key, and finds no capacity while the pool is empty. It routes nothing.
  • hedge cli-proxy connect on a node saves a key that the proxy accepts, even while the proxy serves no model, then runs hedge apply. Apply sends each agent to the proxy only while its route check passes, so connect never routes an agent the proxy does not serve. Connect then says, for each agent, whether it uses the proxy now or keeps its own sign-in. It fails when hedge apply fails. Connect still changes nothing when the proxy does not answer, refuses the key, or answers with a model list it cannot read.

Merge risk

Merge risk: medium. Two-way door.

Tier: non-critical

Own-account balancing is opt-in and off by default, and only the Hub pack's proxy checks have a todo. It is medium, not low, for two reasons. The reconciler's apply loop changes: the provider config adapter, which writes Claude and Codex settings and installs plugins and MCP servers, now runs after the steps instead of before them, and the checks that config waits for run after the steps too. No step reads provider config, and a plugin whose Claude Code a step installs now goes in during the same apply. A T3 setting can no longer wait for a check; no pack has one. Cleanup also changes: Hedge removes only provider settings its record names, and the route as one unit, where the base branch removed any setting that pointed at the proxy's port. So a Codex table of your own now stays, and a route that an older hedge cli-proxy connect wrote without a record stays too (Known issues). hedge cli-proxy connect now runs hedge apply on the node instead of writing settings itself, so connect takes as long as an apply there and fails when it fails. When an adapter before the steps throws, apply still writes provider config, then fails, as on the base branch, and names both errors when provider config fails too. On the hub, the route checks now also fail on an unsafe proxy, which takes Hedge's route out where the base branch kept it. And one existing hub shape now fails apply where the base branch passed: on the both plan, with Claude at its floor and a Codex subscription that works while the proxy lists no Codex model, hedge cli-proxy doctor fails the proxy step. Routing still waits for a passing check, so no machine moves to the proxy earlier than before. Switch-off: none needed; revert or fix forward.

Decisions

Question Answer Who Where
How does a short pool show without blocking setup? A pack check with a todo that exits 4, not a human step: setup waits for every human step 🤖 This PR
Does a To do: from a waiting check fail hedge doctor? No, so setup's last step, "Check everything", passes with an empty pool 🤖 This PR
What does the route check say while the proxy answers but serves no model? A To do: with the login command; down, refused key or foreign table stay Fix: 🤖 This PR
Does a pool below the floor but above 0 still route machines to the proxy? Yes, as before: the route checks only ask whether the proxy serves the model 🤖 This PR
Does the floor count Codex subscriptions on the both plan? No, as before: on both it counts Claude ones; an empty Codex pool gets its To do: from the Codex route check. The doctor does fail while a Codex subscription works but the proxy serves no Codex model 🤖 Review rounds 1 and 2
Should a route check also catch a pool whose only logins expired? Not in this PR: route checks read only the proxy's model list, as on the base branch, and a node has no other signal. This PR adds no path that routes a box 🤖 Review round 3, finding 1
Should Hedge reject model ids that are blank or padded with spaces? No: CLIProxyAPI builds the list from its own model registry, which has no such ids. The check rejects a reply without a list, or with an entry that has no id 🤖 Review round 3, finding 4
Who takes a route off when the pool empties? hedge apply, through the route checks, as for any failed route check. Connect only saves the key. Rounds 2 and 3 had connect clean up too; round 4 found more edge cases in that copy, so I removed it 🤖 Review rounds 2 to 4
Should apply check a check again that already waited in the gate? No: exit 4 means the proxy answered without the agent's model, and no step adds a person's subscription. The next apply sees the change 🤖 Review round 4, finding 4
Should hedge doctor pass on a node that still routes to a pool that emptied? No: the node sends its agent to a proxy that cannot serve it, and doctor's Fix: says hedge apply fixes that. Setup runs apply on the hub and each devbox before its final doctor, so setup does not stop on it 🤖 Review round 5, finding 1
Should connect on the both plan route Codex when your own Claude apiKeyHelper blocks Claude? Yes: connect no longer refuses anything itself. Apply keeps your Claude setting, says so, and still routes Codex when its check passes 🤖 Proof review 9
Should apply remove a provider setting that points at the proxy's port but that Hedge has no record of writing? No: Hedge removes only what its record says it wrote. Removal by port deleted user-written Codex tables 🤖 Proof reviews 6, 8 and 9
Who writes the route to the proxy? Only apply's provider config adapter, which records each key. Connect saves the key and runs hedge apply. Rounds 4 to 9 each found an edge case where two writers and an exact-value guess stood in for a record 🤖 Proof review 9
How does Hedge remove a route? By its record, as one unit. It keeps the whole route with a To do: when removing it would send a key of yours to Anthropic or leave a Codex selector without its table 🤖 Proof review 9
What happens to a route that an older connect wrote without a record? It stays when balancing goes off; hedge cli-proxy disconnect takes it off. The first apply with balancing on and a passing check records it, since it holds Hedge's values. No machine has one: they run Fleet's fleet-proxy route, which Fleet's own record lists 🤖 Proof review 9
What does apply report when provider config fails after an earlier adapter error? Both errors, the earlier adapter's first 🤖 Proof review 9
Does an adapter that fails before the steps stop provider cleanup? No: apply runs the route checks and provider config, then fails with the adapter's error, as the base branch did when provider config ran before Jobs, T3 and identity 🤖 Proof review 8
How often does apply decide config that waits for a check? Once, after the steps: the provider config adapter runs after them, from checks run then. Round 6 decided it before and after the steps, and the first decision dropped Hedge's record of a setting that the second could not undo. The T3 adapter stays before the steps for the peers step, so a T3 setting can wait only for a human step. A route an earlier apply wrote stays while the steps run and comes out at the end if its check fails 🤖 Proof review 7
Where does apply decide that the proxy is safe to route through? In the route checks, which call doctor's safety function. Round 4 held waiting config across the first pass instead; each review round found another adapter the hold reached, so I removed it 🤖 Proof review 5
Should a step that waits for an unfinished human prerequisite keep config out whose check passes? No: the check is the contract for the config, and it now includes safety. The hub has no case where the route check passes on an unsafe proxy 🤖 Proof review 5
Can a node connect to a proxy that holds no subscription? Yes: connect saves an accepted key, and apply routes each agent once the proxy serves it 🤖 Review round 1, finding 1
What does the real proxy answer on /v1/models with no subscriptions? HTTP 200 with {"data":[],"object":"list"}, read on a live hub with CLIProxyAPI 8.0.46 and 0 subscriptions. So an empty pool reads as an empty list, and data: null stays unreadable 🤖 Proof review 1, fresh eyes
Can a hub run a Hub pack newer than its engine, which reads exit 4 as a Fix:? No: the Hub pack ships in the engine repository. Hedge loads it from the running engine checkout (src/cli.ts, the engine source), refuses a pack name that two sources carry (choosePacks in src/reconciler/resolve.ts), and hedge update moves the one checkout. No private pack declares a todo 🤖 Proof review 1, risk finding 5

Known issues

  • A Claude or Codex route that hedge cli-proxy connect wrote before this change has no record, so turning balancing off before any apply records it leaves it in place. The base branch removed such a route by port 8317 (src/adapters/provider-config/stale.ts on feat/cloud-only), which proof review 6 dropped because it deleted Codex tables you wrote yourself. Run hedge cli-proxy disconnect on such a box.

How did you test this code?

The proving test is packs/hub/hub.test.ts, "apply on a hub whose proxy holds none of your subscriptions". It runs the real Hub pack plan on a hub through apply and check, with hedge cli-proxy install|doctor|accounts|check served by cliProxy against a fake CLIProxyAPI that holds 0 subscriptions:

test("installs the proxy, passes its step, keeps Claude Code on its own sign-in, and lists the login as a To do; doctor passes too", async () => {
  const { home, result, options } = emptyHub("claude");
  const fresh = await apply(result, options);
  expect(fresh.ok).toBe(true);
  expect(fresh.findings.map((finding) => [finding.id, finding.todo ?? finding.repair])).toEqual([["check:cli-proxy-accounts", true], ["check:cli-proxy-client", true]]);
  expect(fresh.findings.map((finding) => finding.say.endsWith(`: ${login("claude")}`))).toEqual([true, true]);
  expect(existsSync(join(home, ".local/share/hedge-cli-proxy/cli-proxy-api"))).toBe(true);
  const applied = await apply(result, options);
  expect(applied.ok).toBe(true);
  expect(applied.findings.map((finding) => [finding.id, finding.todo ?? finding.repair])).toEqual([["check:cli-proxy-accounts", true], ["check:cli-proxy-client", true]]);
  expect(existsSync(join(home, ".claude/settings.json"))).toBe(false);
  const doctor = await check(result, options);
  expect(doctor.ok).toBe(true);
  expect(doctor.findings.map((finding) => [finding.id, finding.todo])).toEqual([["check:cli-proxy-accounts", true], ["check:cli-proxy-client", true]]);
});

The first apply on a fresh hub already shows only the two To do: lines, each ending with the login command. The same describe covers the Codex plan and a pool of 1 of 2, which routes Claude Code to the proxy that serves it and still lists the To do.

On the base branch, the same tests fail with "ok": false and Step cli-proxy of the hub pack ran, but does not pass its check., which is the reported failure. On this branch they pass.

Also new or changed:

  • src/cli.test.ts: through main, a waiting check prints To do: …. Apply exits 0 and ends with Applied …, and doctor exits 0.
  • src/reconciler/apply.test.ts: exit 4 with a todo keeps the waiting config out and fails nothing. A todo check that nothing waits for runs after the steps. Exit 4 without a todo, and exit 1 with one, stay a Fix:.
  • packs/hub/lib/cli-proxy.test.ts: the doctor passes with 0 and with 1 of 2 subscriptions and prints the To do. It still fails with an empty pool when the proxy refuses the key, does not answer, has its service down, or runs a foreign plugin. accounts exits 4 below the floor and 0 at it, and fails when it cannot count. check exits 4 when no model is served.
  • packs/hub/lib/cli-proxy.test.ts, after review round 1: connect to an empty pool saves the key and keeps Claude Code and Codex on their own sign-ins. A model list the proxy cannot give fails the check and the doctor. With hub.proxyAccounts at 0, an empty pool passes.
  • src/reconciler/apply.test.ts, after review round 1: a check whose pool is unreadable until a step installs it shows its To do: after the step. A gate Fix: for a check that config waits for becomes a To do: after the step, and the config stays out.
  • src/pack/manifest.test.ts: a todo must be a sentence.
  • packs/hub/hub.test.ts, after proof review 1: "with one working subscription and a proxy that only its step starts, one apply routes Claude Code to the proxy, and doctor passes" runs one apply and then doctor on a hub whose fake proxy service is stopped until the installer starts it. The test's command dispatch now refuses any command that the Hub pack does not run through the engine launcher, and the assertions read each finding's todo flag.
  • src/reconciler/apply.test.ts, after proof review 1: a todo check that nothing waits for and that exits 1 after the steps is a Fix:. A check that config waits for and that fails before the step and passes after it writes the config and drops its Fix:, and doctor then passes. Doctor reads one result of the check for both the config and the finding.
  • packs/hub/lib/cli-proxy-forwards.test.ts, after proof review 1: a handover to a proxy that lists no model runs the real connect on the box, and the hub prints the box's waiting line.
  • packs/hub/lib/cli-proxy.test.ts: the exit-status assertions use the literal 4.
  • packs/hub/hub.test.ts, after proof review 2: the fake proxy answers only after systemctl starts its service. A stopped proxy that its step starts, but whose doctor finds a plugin Hedge did not install, fails the step and writes no Claude route.
  • src/reconciler/apply.test.ts, after proof review 2: a step installs Claude Code, the waiting check passes after it, and provider config, which runs after the steps, installs the plugin. Apply then shows no Fix:.
  • packs/hub/lib/cli-proxy-forwards.test.ts, after proof review 2: box lines that hold a known waiting line plus other text or control characters print nothing from the box. The exact line prints the hub's own message.
  • packs/hub/hub.test.ts, after proof review 3: the stopped-proxy test shows no stale reachability Fix: after the step starts the proxy. The fake proxy starts only when systemctl --user restart or enable --now names hedge-cli-proxy.service and its unit file is installed.
  • src/reconciler/apply.test.ts, after proof review 3: the fake Claude CLI records each plugin's scope. The test asserts a user install, and doctor reports a plugin installed with another scope as missing. A plugin you edited and that no pack enables keeps its "It is yours now" notice through the second config pass.
  • packs/hub/lib/cli-proxy-forwards.test.ts, after proof review 3: a failed handover whose box output holds a key-like string and an ANSI escape prints neither, only the box name and the exit code.
  • packs/hub/hub.test.ts, after proof review 5, asserting at the proxy boundary (each request to the proxy records the route then) and after apply returns: with a plugin Hedge did not install from the start, the route is absent at every request and is never written. After a successful apply, such a plugin appears while the proxy still lists the model: the next apply fails, the route is gone, and it stays absent through the apply after. A hedge-proxy Codex table of your own that points elsewhere survives the failed step, model_provider included. On a hub whose step passes, every request sees the route that the first apply wrote, and the next apply changes nothing.
  • packs/hub/lib/cli-proxy-panel.test.ts, after proof review 5: on the hub, check and check codex exit 1 and print doctor's reason while a plugin Hedge did not install is there, and check exits 1 when the quota-ledger plugin does not match its pin.
  • src/adapters/provider-config/provider-config.test.ts, after proof review 5: a Codex hook keeps its trust while the check it waits for passes, even when its pack's step fails.
  • src/reconciler/apply.test.ts, after proof review 4: a marketplace update fails while the plugin installs, and its Fix: stays.
  • src/adapters/provider-config/provider-config.test.ts, after proof review 4: doctor runs before apply gives a changed Codex plugin to the person, passes, and shows only "It is yours now". After the release and one more apply, the fake Codex still has the plugin installed and disabled, and config.toml keeps it disabled.
  • packs/hub/lib/cli-proxy-forwards.test.ts, after proof review 4: a failed handover names hedge box run box-lane -- hedge cli-proxy connect < ~/.config/hedge/cli-proxy.key.
  • src/reconciler/apply.test.ts, after proof review 7: a route an earlier apply wrote, whose check fails before a step and passes after it, stays in place, and apply changes nothing. A check that passes before a step and fails after it never puts its config in. A check with a todo that exits 4 before a step and 0 after it leaves no To do: and writes its config in the same apply.
  • packs/hub/hub.test.ts, after proof review 7: after hedge cli-proxy connect on a devbox, turning balancing off takes the Claude and Codex routes off at the next apply.
  • packs/hub/lib/cli-proxy-panel.test.ts, after proof review 7: with the panel off, a dangling link at the panel page or plugin path fails the route check.
  • src/pack/manifest.test.ts, after proof review 7: a T3 setting that waits for a check is refused.
  • packs/hub/hub.test.ts, after proof review 8: on a devbox that connect sent to the proxy, which leaves no record, turning balancing off takes the exact Claude and Codex routes off. Your own hedge-proxy selector with a table of your own stays, selector and table, through connect and balancing off. A job id that the Jobs adapter refuses still lets apply take the route to a proxy that turned unsafe out, and apply fails with the job's reason. The two unsafe-proxy tests no longer count installer runs.
  • src/adapters/provider-config/provider-config.test.ts, after proof review 8: Hedge's exact Claude route without a record comes out, and the proxy address beside a key helper of your own stays.
  • packs/hub/lib/cli-proxy-panel.test.ts, after proof review 8: a dangling link at the panel page or plugin fails the check, which says to remove it; after you remove it, install passes and so does the check.
  • packs/hub/hub.test.ts, after proof review 9, through hedge cli-proxy connect and hedge apply: connect routes Claude Code and Codex, and turning balancing off takes both routes off. After an earlier apply wrote only the hedge-proxy table, connect selects it, and turning balancing off takes the table and the selector off together. Connect beside a hedge-proxy table of your own with another name selects nothing, and your table stays when balancing goes off. Hedge's Claude route beside your own ANTHROPIC_AUTH_TOKEN stays when balancing goes off, with a To do:, and leaves once you remove the token. A refused job id and a provider record Hedge cannot read both reach the person, the job's reason first. The connect-then-off test no longer reads Hedge's record file.
  • src/adapters/provider-config/provider-config.test.ts, after proof review 9: a recorded route stays with a To do: while a token of yours would go to Anthropic without it, and leaves once the token is gone. A route with Hedge's values and no record stays.
  • packs/hub/lib/cli-proxy-panel.test.ts, after proof review 9: with the panel on, a link at the panel page or plugin to a file with the pinned bytes fails the route check.
  • packs/hub/lib/cli-proxy.test.ts and cli-proxy-forwards.test.ts, after proof review 9: each connect test runs the real hedge apply path on the node and asserts the settings files it leaves.
  • src/reconciler/apply.test.ts, after proof review 8: doctor shows the To do: of a check with a todo that exits 4 before the step; apply then leaves no To do: and writes the config, and doctor passes.

Each new test of proof review 1 fails on the head before it, 0a628ecb. Each new test of proof reviews 2, 3 and 4 fails when its fix is reverted. Of proof review 5: both unsafe-route hub tests fail on the route outcome when check skips the safety function; the Codex table, T3 and hook-trust tests fail on the round 4 head, f62c9650; the stopped-proxy test fails without the second pass; and the steady-state test fails when the gate takes the route out before the step and writes it back. Of proof review 7: with apply.ts of 01d4b1b5, the tests that a route an earlier apply wrote stays in place and that a check passing only before a step never writes its config fail; without connect's record, the connect-then-off hub test fails; with existsSync, the dangling-link panel test fails; and without the T3 rule, the manifest test fails. The new exit-4 case with a todo passes on both heads. Of proof review 8: without the exact-route rule, the no-record hub test and the provider-config test fail; with a rule that ignores the Codex table, or with round 7's connect record restored, the selector-and-table test fails, and the record also fails the no-record test; without the catch, the Jobs test fails; without the link message, the dangling-link test fails; and when apply ignores todo, the rewritten exit-4 test fails. Of proof review 9: with the old connect, which wrote the route itself, the table-then-connect, custom-table and ANTHROPIC_AUTH_TOKEN hub tests fail; with the stranding rule off, the ANTHROPIC_AUTH_TOKEN hub and provider-config tests fail; when apply writes part of a route, the custom-table hub test fails; without the combined error, the two-errors test fails; and without the link check, the panel-on link test fails.

bun run typecheck passes. bun test at bd521d3a: 4322 pass and 17 fail. 15 also fail on a clean devbox checkout: the privacy scan (no gitleaks), tracker (git rewrites the GitHub origin), and the page code parser test. The other 2, in packs/slack/slice.test.ts, ran under load and pass alone. 94084a07 changes only the CHANGELOG. bun scripts/build-page.ts builds the site. The text changes on the site are the hub.proxyAccounts question and the Proxy panel risk on /packs/hub/. Nothing ran against a real home directory or a real machine.

Review: GPT-6.2 Sol at high effort, round 1 at 32cb807e, found 2 blockers, 3 should-fix and 1 nit. I fixed all of them but finding 5, which the Decisions table answers. Round 2 at 08590ec3 found 2 blockers, 1 should-fix and 1 nit: reconnect left routes on an empty pool, a model list with bad entries read as empty, the both plan hid a Codex serving failure, and 5 added comments. I fixed all 4 at a360a3cf, and each new test fails on the old code. Round 3 at a360a3cf found 1 blocker and 3 should-fix. I fixed the two about reconnect cleanup at b0b6d785, and each new test fails on the old code. The Decisions table answers the other two. Round 4 at b0b6d785 found 4 should-fix. Finding 3 was another edge case of connect's cleanup, which 1731ae4b removes in favour of hedge apply. Finding 4 is in the Decisions table. Findings 1 and 2 are as on the base branch: apply removes a Claude proxy address equal to the proxy's own when the route check does not pass, and a Codex-only node refuses a linked Codex config before it saves the key. Round 5 at 1731ae4b found 1 blocker and 2 should-fix. The Decisions table answers findings 1 and 3. For finding 2, connect now tells you to run hedge apply; the message for a linked Codex config is as on the base branch. The final read at 6abe2ac5 found 1 should-fix: a subscription list with a row that names no provider read as an empty pool. b17861b9 fixes it, and the outage test now reaches the model list. The read of that fix at b17861b9 found 1 nit, a reply of null without the clear message, which 11ffa623 fixes as the reviewer suggested. Proof review 1 at 0a628ecb (correctness, risk and fresh-eyes lenses) found 1 blocker, 3 major, 3 minor, 1 nit and 3 test rewrites. 8cdbcf65 fixes the blocker, both apply majors, the fresh-eyes minor and the test rewrites in the reconciler and the hub test. 5a473af2 relays the box's waiting line and asserts the literal 4. 82302f9a rewords the route To do: and adds doctor's closing line to SETUP.md. The Decisions table answers the pack-version finding and the fresh-eyes question about data: null. Proof review 2 at 82302f9a found 2 blockers, 1 major, 1 minor and 1 test rewrite. b632f1ed keeps config out when its pack's step failed, makes the second config pass replace the first pass's config lines, and makes the fake proxy start with its service. bac84008 makes the handover match exact box lines and print the hub's own message, and rewords the CHANGELOG. Proof review 3 at bac84008 found 2 blockers, 2 minor and 2 test rewrites. e41fa934 stops the hub from printing a box's output when connect fails. ada15732 takes back config that waits for a check of a pack whose step failed, reruns the waiting check after a failed step, keeps first-pass notices, and rewrites the proxy fake and the plugin scope test. Proof review 4 at ada15732 found 2 blockers, 3 major and 2 test rewrites. f62c9650 replaces the take-back path: config that waits for a check of a pack with steps is held until those steps ran, and the second pass never drops a table the first pass kept. It keeps a first-pass Fix: unless the second pass says it again or reports its operation done, names hedge box run as the retry for a failed handover, and runs doctor before a Codex plugin release. Proof review 5 at f62c9650 found 6 blockers, 1 major and 3 test rewrites; all six blockers came from the hold. 23a8e859 replaces the hold with a route gate that checks the proxy's safety, removes the hold from every adapter, keeps the second pass only for a check that passes after the steps, removes the added comments, and rewrites the tests to assert at the proxy boundary. The Decisions table answers the human-prerequisite finding. Proof review 6 at 23a8e859 found 4 blockers, 3 major and 1 test rewrite. 01d4b1b5 replaces the second pass's special cases with one config decision before and after the steps that reruns every config adapter when the decision changes, fails the route while panel files are on disk with the panel off, removes provider settings only by Hedge's record, asserts the route was gone when the proxy step starts, and checks Codex hook trust by hash. Proof review 7 at 01d4b1b5 found 3 blockers, 3 major and 1 test rewrite. 4c927f99 decides config that waits for a check once, after the steps, which removes the second config pass and its comment, and adds the exit-4 case with a todo. d2ec0ad3 records the Claude and Codex routes that connect writes. 6a3c0ba0 counts a dangling link at a panel path as still there. Proof review 8 at 6a3c0ba0 found 2 blockers, 3 major, 1 minor and 2 test rewrites, all from connect's record or the new order. 9fa87217 and 6efc4508 drop connect's record and own the proxy route by its exact values, which removes the race, leaves your own selector and table alone, and takes the route off boxes connected without a record. debb77e9 runs provider config when an earlier adapter throws. d984961d tells you to remove a link at a panel path before install. 540aaefd runs the exit-4 case's check before the step and drops the installer counts. f2cb11a4 brings the CHANGELOG up to date. Proof review 9 at f2cb11a4 found 3 blockers, 2 major and 1 test rewrite. All three blockers came from two writers of one route and the exact-value guess. bd521d3a makes apply the only writer: connect saves the key and runs hedge apply, apply removes a route only by its record and as one unit, keeps it with a To do: when removing it would send a key of yours to Anthropic or strand a Codex selector, and the exact-value fallback is gone. f49f32d7 reports both errors when provider config fails after an earlier adapter error. 948e708e adds the panel-on link test. The private-record assertion is gone. The Codex hook test keeps its trust assertion: no fake Codex runs hooks, and running a real one needs a live Codex session. The hash format is Codex's own trust state, and the base branch's test "trusts the Codex hooks a pack owns" pins a literal hash for it.

Checked live, read-only: the new hub's CLIProxyAPI 8.0.46 with 0 subscriptions answers /v1/models with HTTP 200 and {"data":[],"object":"list"}, the shape the fake proxy sends. Not checked: a full hedge apply and hedge doctor against that hub.

Remaining risk: when every login in the pool expired but CLIProxyAPI still lists their models, a node's route check passes and sends the agent to the proxy. The base branch behaves the same. The hub's hedge doctor shows the expired logins and the To do:.

🤖 Generated with Claude Code

Silthus and others added 16 commits November 19, 2026 09:05
With fewer working subscriptions than hub.proxyAccounts, none included,
the cli-proxy step installs and starts the proxy and passes. hedge apply
and hedge doctor show a To do line with the login command, for the Claude
and the Codex pool, and nothing fails.

A pack check can now name a todo. When its command exits 4, Hedge prints
the todo as a To do line, keeps the config that waits for the check out,
and fails neither apply nor doctor. Apply runs such a check after the
steps, so it can read what a step installed. hedge cli-proxy check exits 4
while the proxy answers but serves no model for the agent, so each machine
stays on its own sign-in until the pool has a subscription. The new
hedge cli-proxy accounts counts the working subscriptions. A proxy that is
down, refuses the key, or runs a foreign plugin still fails as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- connect saves a key the proxy accepts, and routes each agent only once
  the proxy serves its model, so a node can connect to an empty pool.
- With hub.proxyAccounts at 0, an empty pool passes the doctor: the
  account count, not the floor, decides whether a missing model is wrong.
- A model list the proxy cannot give fails the check and the doctor
  instead of reading as an empty pool.
- Apply checks a waiting check again after the steps, so a fresh hub
  shows its To do instead of a stale Fix from before the proxy ran.
- Each To do ends with the login command, so it pastes as is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Connect again takes Hedge's routes off an agent the proxy no longer
serves. A model list with an entry that has no model id fails, so it
never reads as an empty pool. On the both plan, the doctor fails while a
Codex subscription works but the proxy serves no Codex model. The added
comments are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reconnect to an empty pool takes the proxy address off Claude Code only
while Hedge's key helper goes with it. When Hedge cannot take its route
off Codex, because the config is a link or cannot be written, connect
says Codex may still use the proxy instead of failing after the key is
saved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Connect to a proxy that serves an agent no model now saves the key and
changes no agent settings. hedge apply already takes Hedge's route off
an agent whose route check waits for the person, so the cleanup that
connect did twice is gone, with its edge cases. A hub test shows apply
taking Claude Code off the proxy once its pool empties.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A management reply without a list, or with a row that names no
provider, now fails the doctor and hedge cli-proxy accounts instead of
reading as an empty pool. The outage test now reaches the model list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve src/cli.ts printReport: keep the base's printFindings helper and
teach it the todo finding, so held findings print To do too; keep this
branch's doctor line for waiting checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On a hub whose proxy is stopped, the route check failed in the gate, the
step started the proxy, and the check then passed, but apply kept the
stale Fix and left Claude Code's route out, so setup's final doctor failed.
Apply now runs each check with a todo again after the steps, unless it
passed or waited in the gate. Its finding takes the new result: a pass
drops the old one, and any failing code is reported, not only 4. When
config waits for a check that passes now, apply reconciles that config.
Doctor reads the gate's result of a check that config waits for, so the
config and the finding never disagree.

The hub test's command dispatch now refuses any command the Hub pack does
not run through the engine launcher, and its assertions read the todo flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Connect on a box exits 0 when the proxy serves none of its agents yet,
and prints that the agent keeps its own sign-in until the proxy serves
it. The handover dropped that line, so the person did not learn that
the box waits. The hub now says each such line with the box's name.

The proxy tests assert the documented exit status 4 itself, not the
constant the code exports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…line

The route check's To do said the proxy holds none of the agent's
subscriptions, which is wrong when one works but the proxy lists no model
for it. It now says which agent's model the proxy does not list, and
points to hedge cli-proxy doctor on the hub, which tells the two cases
apart. The hedge-hub skill says the same.

Step 8 of SETUP.md lists doctor's closing line for To do lines that wait
for the person, and says they do not stop setup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… findings

When a pack's step failed in this apply, the second config pass no longer
writes config that waits for that pack's checks. The second pass now
replaces the findings that the config adapter gave in the first pass, so
a plugin that waited for Claude Code leaves no stale Fix line. The proxy
test fake now answers only once the service starts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The handover matched any box line that ended with a fixed suffix and
echoed it, so a box could put any text or control characters in the
hub's output. The hub now matches the two exact lines that connect
prints and prints a message of its own, which tells the person to run
hedge apply on the box. The CHANGELOG says so, and names the second
config pass rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When hedge cli-proxy connect exited non-zero, the hub copied the box's
stderr or stdout into its own output, which could carry the proxy key or
control characters. The hub now names the box and the exit code, and
points to hedge cli-proxy check on the box.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A running proxy could pass its route check before the step, so the first
config pass wrote the route, and then the pack's step failed on a plugin
Hedge did not install. The second config pass now takes out the config
that waits for a check of a pack whose step failed in this apply.

Apply runs a waiting check again after the steps also when its pack's
step failed, so its line shows what the check finds then. The second
pass replaces only the first pass's config lines that it reads again,
so the notice that an edited plugin is yours now stays. The Codex
notice carries no repair, as the Claude one.

The proxy fake now starts only when the installed proxy unit is
restarted or enabled with --now by its real name. The fake Claude CLI
records each plugin's scope, and the test asserts a user install.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus and others added 13 commits November 19, 2026 15:51
…lines

Config that waits for a check of a pack with steps in this apply no longer
enters the first config pass. The gate holds it: the config adapter leaves
its keys, plugins and MCP servers as they are, so a route that an earlier
apply wrote stays and an absent one stays absent. Apply runs its check
after the steps and writes the config in the second pass only when the
pack's steps passed and the check passes then. When the check fails, the
config leaves as it does for any failing check. The round 3 withdraw path
is gone, so the second pass never drops a table the first pass kept, such
as a hedge-proxy Codex table of your own.

The second pass drops a first-pass line only when it says the same line
again or reports that the line's operation now succeeded. The config
adapter names those operations: plugin and marketplace changes, MCP server
changes, and reaching Claude Code or Codex. A Fix for an operation the
second pass skips, such as a failed marketplace update, stays.

A failed handover names the hub-side command that sends the same key
again: hedge box run <box> -- hedge cli-proxy connect < the key file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On the hub, hedge cli-proxy check and its codex form now fail while
hedge cli-proxy doctor finds the proxy unsafe: a plugin Hedge did not
install, or panel files that do not match their pins. Both use doctor's
own safety function. The route config waits for these checks, so a
failing check keeps the route out, or takes Hedge's route out, through
the gate's ordinary failing-check path in the first config pass, before
the proxy step runs. A route to a safe proxy stays in place.

The round 4 hold is gone: Plan.held, the gate's hold for packs with
steps, and the hold in the config adapter, the plugin and MCP server
lookups, and the hook trust. The second config pass keeps only its
round 1 purpose: after the steps, it runs again each check that config
waits for, or that has a todo, and that did not pass or wait before,
and writes the config of each check that passes then. It drops a line
of the first pass only when it says the same line again or its
operation now succeeds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After the steps, apply runs again every check that config waits for and
every check with a todo, and gates config with the same function as the
first pass. When that changes which config waits, it runs every adapter
that writes config again, the provider settings and T3's, so a route
whose check fails at the end of apply leaves, and config whose check
first passes after a step goes in, whatever exit code the check gave
first.

With the Proxy panel off, the hub's route check fails while the panel
page or plugin is still there, whatever it holds.

Hedge no longer removes a setting because it points at port 8317: it
removes only what its record says it wrote, or Hedge's exact value for a
waiting route.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…what it recorded

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Apply decided gated config twice: once before the steps and again
after them, rerunning config adapters when the decision changed. The
first decision dropped Hedge's record of a setting the second could
not undo, or made Hedge's own old value look like a user edit.

The provider config adapter now runs once, after the steps. Before it,
apply runs each check that config waits for, and each check with a
todo, once, and decides the waiting config from those results. The
other adapters still run before the steps. The T3 adapter must, as the
peers step needs T3, so a T3 setting can wait only for a human step.
No pack has a T3 setting that waits for a check.

This removes the second config pass, the rerun of adapters, and the
resolved ids that plugins and MCP servers reported for it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Connect wrote the Codex selector and table, and the Claude proxy
address and key helper, without an ownership record. Apply now removes
only settings its record names, so turning own-account balancing off
left the route behind. Connect now adds what it sets to the same
record apply uses, so apply takes the route off with the workflow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the panel off, the route check used existsSync, which follows
links, so a dangling link at either panel path passed while doctor and
install reject it. The check now uses lstat.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Connect recorded the routes it wrote, which raced a concurrent apply and
claimed a hedge-proxy selector the user had set beside a table of their
own. Boxes connected before that change had no record, so turning
balancing off left their route in place.

Hedge now owns a provider setting when its record names it, or when the
proxy route holds exactly the values Hedge writes: the Claude proxy
address and key helper, or the Codex hedge-proxy selector and table.
Apply removes that route whenever it is not wanted, with balancing on or
off, and leaves it alone while any part holds another value. Connect
writes no record, and the route values live in one engine module that
the Hub pack reads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Provider config now runs after the steps, so an adapter that ran before
it on the base branch, such as Jobs on a job id it refuses, could throw
before the route checks and provider cleanup ran. A route to a proxy
that turned unsafe then stayed until the unrelated failure was fixed.

When an adapter before the steps throws, apply now runs the route
checks and the provider config adapter, then fails with the adapter's
error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Install refuses a link at the panel's page or plugin path, so the route
check's advice to run hedge cli-proxy install could not fix a dangling
link there. The safety check now names the link and says to remove it,
then run install. The test follows that advice to a passing check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test of a check with a todo that exits 4 before a step never ran
the check before the step. It now runs doctor first, which shows the
To do, then apply, which leaves no To do and writes the config.

Two hub tests also asserted how many times the installer ran. They now
assert only the final settings and the failure report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Removing a lone proxy address that matched Hedge's value would leave an
older ANTHROPIC_AUTH_TOKEN beside it, which sends Claude Code to
Anthropic with the proxy's key. The route is now Hedge's only when each
of its settings is there with Hedge's exact value: the Claude proxy
address and key helper, or the Codex selector and table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gelog

The changelog still described two config passes and cleanup by record
alone. It now says apply decides provider config once after the steps,
runs it even when an earlier adapter fails, owns the proxy route by its
exact values, and names the fix for a link at a panel path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus and others added 4 commits November 19, 2026 18:06
… the original first

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the panel on, pinned bytes or not

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rd, as one unit

hedge cli-proxy connect saves the key and runs hedge apply, so every route
Hedge writes has a record. Apply writes a provider's route keys together or
not at all, removes them together, and keeps the route with a To do when
removing it would send a key of yours to Anthropic or leave a Codex
selector without its table. The exact-value fallback is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…angelog

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant